home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / SOUND / CRYS270.ZIP / CRYSPLAY.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-06-26  |  4.2 KB  |  270 lines

  1. ;**************************************************************************
  2. ;*    Ce module contient les routines servant à rechercher les
  3. ;*    informations sur la musique dans le module CRYS290
  4. ;* Programmé par Sébastien Granjoux
  5. ;* Commencé le 26/12/93
  6. ;* Dernière modif 05/01/95
  7.  
  8.  
  9. IDEAL
  10. P386N
  11. MODEL SMALL
  12.  
  13. EXTRN    PEEKMOD:far
  14.  
  15. PUBLIC    GetMixRate
  16. PUBLIC    GetName
  17. PUBLIC    GetModInf
  18. PUBLIC    GetTempo
  19. PUBLIC    GetPattern
  20. PUBLIC    GetVoice
  21. PUBLIC    GetVoiceByte
  22.  
  23. INCLUDE "CRYSDEV.INC"
  24. INCLUDE "CRYSLOAD.INC"
  25.  
  26. EXTRN    Position:far
  27. EXTRN    Line:far
  28. EXTRN    GETMODPOS:far
  29.  
  30. DATASEG
  31.  
  32. NoteTab:    DB  0D0h,0C4h,0B9h,0AFh,0A5h,09Bh
  33.         DB  093h,08Bh,083h,07Bh,074h,000h
  34.  
  35. HIGH_NOTE    EQU    0DCh
  36.  
  37. CODESEG
  38.  
  39. ;************************************************************************
  40. ;*    Renvoit le nom de la musique (28 octets de long) ou d'un instrument
  41. ;*    Attention cette fonction marche qu'après un LOADMOD et avant
  42. ;*    un SETMOD
  43. ;*
  44. ;* Entrée:
  45. ;*    BL    numero de l'instrument (0 = nom du module)
  46. ;*    ES:DI    buffer où copier le nom musique
  47.  
  48. PROC    GetName
  49.  
  50.     push    ds
  51.     mov    ax,SEG Comments
  52.     mov    ds,ax
  53.     ASSUME    ds:SEG Comments
  54.     mov     si,OFFSET Comments
  55.     xor    bh,bh
  56.     shl    bx,5
  57.     add    si,bx
  58.  
  59.     mov    cx,NAME_LEN
  60. @@next_char:
  61.     lodsb
  62.     or    al,al
  63.     je    @@fill_with_space
  64.     cmp    al,32
  65.     jae    @@no_control
  66.     mov    al,' '
  67. @@no_control:
  68.     stosb
  69.     dec    cx
  70.     jne    @@next_char
  71. @@fill_with_space:
  72.     mov    al,' '
  73.     rep    stosb
  74.  
  75.     pop    ds
  76.     ASSUME    ds:_DATA
  77.  
  78.     ret
  79.  
  80. ENDP
  81.  
  82. ;***************************************************************************
  83. ;*    Renvoit le nombre de position totale de la musique
  84. ;* Sortie:
  85. ;*    AL    nombre de position totale
  86. ;*    AH    nombre de voix du mod
  87.  
  88. PROC    GetModInf
  89.  
  90.  
  91.     push    ds
  92.     mov    ax,SEG Sequence
  93.     mov    ds,ax
  94.  
  95.     ASSUME    ds:SEG Sequence
  96.  
  97.     mov    ax,[ds:OFFSET LastPos]
  98.     sub    ax,OFFSET Sequence
  99.     shr    ax,1
  100.  
  101.     mov    ah,[ds:NbVoice]
  102.  
  103.     pop    ds
  104.     ASSUME    ds:_DATA
  105.  
  106.     ret
  107.  
  108. ENDP
  109.  
  110.  
  111. ;***************************************************************************
  112. ;*    Renvoit le tempo dans al et ah
  113. ;*
  114. ;* Sortie:
  115. ;*    AL    tempo normale
  116. ;*    AH    tempo étendue
  117.  
  118. PROC    GetTempo
  119.  
  120.     push    ds
  121.     mov    ax,SEG Sequence
  122.     mov    ds,ax
  123.  
  124.     ASSUME    ds:SEG Sequence
  125.  
  126.     mov    ah,[ds:OFFSET Bpm]
  127.     mov    al,[ds:OFFSET Tempo]
  128.  
  129.     pop    ds
  130.     ASSUME    ds:_DATA
  131.  
  132.     ret
  133.  
  134. ENDP
  135.  
  136. ;***************************************************************************
  137. ;*    Renvoit la position dans la séquence ainsi que le pattern et la
  138. ;*    ligne
  139. ;*
  140. ;* Sortie:
  141. ;*    AH    position dans la séquence
  142. ;*    AL    pattern
  143. ;*    DL    ligne
  144.  
  145. PROC    GetPattern
  146.  
  147.     push    ds
  148.     mov    ax,SEG Line
  149.     mov    ds,ax
  150.     ASSUME    ds:SEG Line
  151.  
  152.     call    GetModPos
  153.     mov    dx,ax
  154.     shl    dx,2
  155.     shr    dl,2
  156.  
  157.     mov    ax,[word ptr ds:OFFSET Line+2]
  158.     sub    ax,[ds:OFFSET patternseg]
  159.     shr    ax,4
  160.     div    [ds:NbVoice]
  161.  
  162.     mov    ah,dh
  163.     pop    ds
  164.     ASSUME    ds:_DATA
  165.  
  166.     ret
  167.  
  168. ENDP
  169.  
  170. ;*************************************************************************
  171. ;*    Donne des informations sur une voix
  172. ;*
  173. ;* Entrée:
  174. ;*    BL    numero de la voix
  175. ;*
  176. ;* Sortie:
  177. ;*    CL    note
  178. ;*    CH    volume
  179. ;*    DL    instrument
  180. ;*    DH    effet
  181.  
  182. PROC    GetVoice
  183.  
  184.     push    ds
  185.  
  186.     ASSUME    ds:_DATA
  187.     mov    ax,SEG Voice1
  188.     mov    ds,ax
  189.     ASSUME    ds:SEG Voice1
  190.     mov    al,SIZE VOICE
  191.     mul    bl
  192.     mov    si,ax
  193.     add    si,OFFSET Voice1
  194.  
  195.     mov    ax,[(VOICE PTR ds:si).note1]
  196.     mov     dl,[(VOICE PTR ds:si).inst]
  197.     mov    dh,[(VOICE PTR ds:si).effnb]
  198.     mov    ch,[(VOICE PTR ds:si).volume]
  199.  
  200.     pop    ds
  201.     ASSUME  ds:_DATA
  202.  
  203.     shl    ax,2
  204.     mov    cl,0Ch
  205.     jz    @@find_note
  206.     mov    cl,70h
  207.     cmp    ax,HIGH_NOTE
  208.     jb    @@find_oct
  209. @@next_oct:
  210.     shr    ax,1
  211.     sub    cl,10h
  212.     cmp    ax,HIGH_NOTE
  213.     jae    @@next_oct
  214.  
  215. @@find_oct:
  216.     mov    si,OFFSET NoteTab
  217.     cmp    al,[ds:si]
  218.     ja    @@find_note
  219. @@next_note:
  220.     inc    si
  221.     inc    cl
  222.     cmp    al,[ds:si]
  223.     jbe    @@next_note
  224. @@find_note:
  225.  
  226.     ret
  227. ENDP
  228.  
  229. ;*************************************************************************
  230. ;*    Retourne l'octet actuellement joué
  231. ;*
  232. ;* Entrée:
  233. ;*    BL    numero de la voix
  234. ;*
  235. ;* Sortie:
  236. ;*    AL    octet courant
  237.  
  238. PROC    GetVoiceByte
  239.  
  240.     push    bx
  241.     push    bx
  242.     call    far PEEKMOD
  243.     pop    bx
  244.     ret
  245.  
  246. ENDP
  247.  
  248. ;***************************************************************************
  249. ;*    Recupère la fréquence de restitution
  250. ;*
  251. ;* Sortie:
  252. ;*    AX    frequence de restitution /10
  253.  
  254. PROC    GetMixRate
  255.  
  256.     push    ds
  257.     ASSUME    ds:SEG MixRate
  258.     mov    ax,SEG MixRate
  259.     mov    ds,ax
  260.     mov    ax,[ds:OFFSET MixRate]
  261.     pop    ds
  262.     ASSUME    ds:_DATA
  263.  
  264.     ret
  265.  
  266. ENDP
  267.  
  268. ENDS
  269.  
  270. END